<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Name Submission</title>

<script type="text/javascript">

function validateForm()
{
  var result = true;
  
  // varibles for the name
  var firstName=document.forms["nameForm"]["first"].value;
  var midName=document.forms["nameForm"]["middle"].value;
  var lastName=document.forms["nameForm"]["last"].value;

  var alphaExp = /^[a-zA-Z]+$/;
  
  // check first name exists
  if (firstName==null || firstName=="")
  {
	  alert("First name must be filled out");
	  result = false;
	  
  // check if only contains letters
  }else if(!alphaExp.test(firstName)){
	  alert("First name must contain letters only");
	  result = false;
  }
  
  //check first middle name is letters only
  if(midName != "" && !alphaExp.test(midName)){
      alert("Middle name must contain letters only");
      result = false;
  }
  
  // check last name
  if (lastName==null || lastName=="")
  {
	  alert("Last name must be filled out");
	  result = false;

  // check if only contains letters
  }else if(!alphaExp.test(lastName)){
      alert("Last name must contain letters only");
      result = false;
  }
  
  if (result == false){
	  return false;
  }
}
</script>

</head>
<body>
    Welcome to the Graduate Admissions System.
    
    Please provide your name.
    
    <!-- Prompts user for name using textboxes -->
    <form method="GET" name="nameForm" action="/Application_Submission/student/country.jsp"  onsubmit="return validateForm()">
        First Name: <input type="text" size="20" name="first" maxlength="20"/><p />
        Middle Name: <input type="text" size="20" name="middle" maxlength="20"/><p />
        Last Name: <input type="text" size="20" name="last" maxlength="20"/><p />
        
    <input type=submit name="Submit" />
    </form>
        
</body>
</html>